<?php
namespace addon\cms\logic;
use app\common\logic\LogicBase;
use tpfcore\Core;
use \tpfcore\util\Config;
class MiniModule extends LogicBase
{

    public function saveMiniModule($data){
    	$validate=Core::addonValidate($this->name);
        $validate_result = $validate->scene("edit")->check($data);
        if (!$validate_result) {
            return [RESULT_ERROR, $validate->getError(), null];
        }

        $update_config['mimi_program']['module'][$data['id']]=$data;

        Config::mult_array_merge(APP_PATH."extra/config.php",$update_config);

        return [RESULT_SUCCESS,"操作成功",url('cms/MiniModule/index')];

        
    }
    public function getMiniModule($id=0){
        $module = config("config.mimi_program")['module'];
        return $id?$module[$id]:$module;
    }
    public function delMiniModule($data){
        $result=self::deleteObject($data,true);
        if($result){
            return [RESULT_SUCCESS,"操作成功",null];
        }else{
            return [RESULT_ERROR,"操作失败",null];
        }
    }
}